package com.ellricky.baselib.ui.base;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.andr.common.ui.activity.BaseToolBarActivity;
import com.andr.common.ui.mvp.BasePresenter;

import com.ellricky.baselib.R;
import com.ellricky.baselib.cache.LocalCacheUtil;
import com.ellricky.baselib.widget.TabVpView;

import java.util.List;

public abstract class BaseTabVpActivity extends BaseToolBarActivity<Void, BasePresenter<Void>> {

    protected TabVpView tabVp;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LocalCacheUtil.setIsReloadData(true);
    }

    @Override
    protected void onPause() {
        super.onPause();
        LocalCacheUtil.setIsReloadData(false);
    }

    @Override
    public int getContentLayout() {
        return R.layout.base_layout_tab_vp;
    }


    @Override
    protected void initUIView() {
        super.initUIView();
        mTvTitle.setText(getTitleRes());

        tabVp = findViewById(R.id.tabVp);

        List<Fragment> fragments = getFragmentList();

        List<String> tList = getTabTitleList();

        tabVp.setUp(getSupportFragmentManager(), fragments, tList);

    }



    @NonNull
    public abstract List<Fragment> getFragmentList();

    @NonNull
    public abstract List<String> getTabTitleList();

    public abstract int getTitleRes();

}
